package com.goods.business.service.impl;

import com.goods.business.mapper.ProductStockMapper;
import com.goods.business.service.ProductStockService;
import com.goods.common.vo.business.ProductStockVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**********************
 *
 *@Author 闫星忠
 *@Time 2021/12/17  16:36
 *
 */
@Service
public class ProductStockServiceImpl implements ProductStockService {


    @Autowired
    private ProductStockMapper productStockMapper;
//    分页展示物资库存信息列表

    @Override
    public PageVO<ProductStockVO> findProductStocks(String categoryKeys, String name) {
        String oneCategoryId = "";
        String twoCategoryId = "";
        String threeCategoryId = "";
        if (!StringUtils.isEmpty(categoryKeys)){
            String[] strings = categoryKeys.split(",");
            oneCategoryId=strings[0];
            twoCategoryId=strings[1];
            threeCategoryId=strings[2];
        }
        List<ProductStockVO> productStockVOS=productStockMapper.findProductStocks(oneCategoryId,twoCategoryId,threeCategoryId,name);
        return new PageVO<>(productStockVOS.size(),productStockVOS);
    }
}
